package helpers;


public class StringHelpers {
    public static int getHash(String str) {
        int hash = 0;
        for (int i = 0; i < str.length(); i++) {
            int symbolCode = str.charAt(i) - '0';
            hash += symbolCode * (1 << symbolCode);
        }

        return hash;
    }

    public static int parseInt(String str) {
        int res = 0;

        try {
            res = Integer.parseInt(str);
        } catch (NumberFormatException e) {
        }

        return res;
    }

    public static long parseLong(String str) {
        long res = 0;

        try {
            res = Long.parseLong(str);
        } catch (NumberFormatException e) {
        }

        return res;
    }
}
